package com.yd.app.service.mobile.agreementService;

import com.yd.app.mapper.AgreementMapper;
import com.yd.app.service.common.BaseService;
import com.yd.domain.business.Agreement;
import com.yd.domain.commom.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 优惠券Service
 * Created by sunxianhui on 2018/3/9.
 */
@Service
public class MAgreementService extends BaseService {

    @Autowired
    AgreementMapper agreementMapper;
    public PageModel getAgreementList(Agreement agreement, int pageIndex, int pageSize) {
        PageModel pm = new PageModel();
        int startRow = getStartRow(pageIndex, pageSize);
        List<Agreement> agreementList = agreementMapper.getAgreementList(agreement, startRow, pageSize);
        int count = 0;
        if (pageIndex == 1) {
            //查询总条数
            count = agreementMapper.getAgreementListCount(agreement);
            pm.setCount(count);
        }
        pm.setList(agreementList);
        return pm;
    }

    /**
     * @Author: zy
     * @Desc:
     * @Date:  2018/3/26
     * @Param
     */
    public Agreement getXyByType(String xyType) {
        Agreement agreement=new Agreement();
        agreement=agreementMapper.getXyByType(xyType);
        return agreement;
    }
}